//
//  FZBrowseCollectionViewCell.swift
//  FZImageBrowser
//
//  Created by 李雷川 on 16/5/28.
//  Copyright © 2016年 李雷川. All rights reserved.
//

import UIKit
import QuartzCore
import CoreGraphics
public class FZBrowseCollectionViewCell: UICollectionViewCell {
    public let zoomScrollView = FZBrowseZoomScrollView()
    let progressLayer = CAShapeLayer.init();
    override init(frame: CGRect) {
        super.init(frame: frame)
        buildUI()
    }
    
    
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    func buildUI(){
//        self.backgroundColor = UIColor.black
//        contentView.backgroundColor = UIColor.black
        contentView.addSubview(zoomScrollView)
        setupProgress()
        
    }
    func setupProgress() {
        self.layer.addSublayer(progressLayer);
        let center = contentView.center
        progressLayer.frame = CGRect.init(x: center.x - 20, y: center.y, width: 40, height: 40);
        progressLayer.cornerRadius = 20.0
        progressLayer.backgroundColor = UIColor.init(white: 0.0, alpha: 0.5).cgColor
        let rect = progressLayer.bounds.insetBy(dx: 7, dy: 7)
        let path = UIBezierPath.init(roundedRect: rect, cornerRadius: 20);
        progressLayer.path = path.cgPath
        progressLayer.fillColor = UIColor.clear.cgColor
        progressLayer.strokeColor = UIColor.white.cgColor
        progressLayer.lineWidth = 4.0
        progressLayer.lineCap = CAShapeLayerLineCap.round
        progressLayer.strokeStart = 0
        progressLayer.strokeEnd  = 0
        progressLayer.isHidden = true
        contentView.layer.addSublayer(progressLayer)
    }
    func resetProgressLayer()  {
        progressLayer.strokeStart = 0
        progressLayer.strokeEnd  = 0
        progressLayer.isHidden = true
    }
    
}
